package org.example.struct.array2;

import java.util.Arrays;

/**
 * @author liyishan
 * @date 2024/3/27 10:08
 * @apiNote
 */

public class Test02580CountWays {
    static final int MOD = 1000000007;


    public int countWays(int[][] ranges) {
        Arrays.sort(ranges,(a,b) ->a[0] - b[0]);
        int n = ranges.length;
        int res = 1;
        for(int i = 0; i < n;){
            int r = ranges[i][1];
            int j = i+1;
            while(j<n && ranges[j][0] <= r){
                r = Math.max(ranges[j][1],r);
                j++;
            }
            res = res* 2 % MOD;
            i = j;
        }
        return res;
    }
}
